<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    input{
      display: block;
      width: 60px;
      height: 40px;
      margin: 100px auto;
    }
    .box{
      width: 180px;
      height: 40px;
      background-color: pink;
      text-align: center;
      line-height: 40px;
      margin: 160px auto;
      display: none;
    }
  
  </style>
</head>
<body>
  <input type="button" value="注册">
  <div class="box">恭喜注册成功!</div>
  <script>
    //炸弹型定时器
    var btn = document.querySelector('input');
    var box = document.querySelector('.box');
    
    btn.onclick = function(){
      box.style.display = 'block';
      setTimeout(function(){
        box.style.display = 'none';
      },3000);
    } 
  </script>
</body>
</html> -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    .big{
      width: 200px;
      margin: 0 auto;
      text-align: center; 
    }
    .box{
      font-size: 100px;
      font-weight: 700;
    }
  </style>
</head>
<body>
  <div class=" big">
    <input type="button" value="开始">
    <input type="button" value="停止">
    <div class="box">10</div>
  </div>
  <script>
    //闹表是定时器
    var start = document.querySelector('input:nth-child(1)');
    var stop = document.querySelector('input:nth-child(2)');
    var box = document.querySelector('.box');
    var step = 1;
    var timeID = null;
    start.onclick = function(){
      timeID = setInterval(function(){
        box.innerText -= step;
      }, 1000);
    }
    stop.onclick = function(){
     clearInterval(timeID);
    };
  </script>
</body>
</html>